package com.csjbot.blackgaga;

import android.content.Intent;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.csjbot.blackgaga.base.BaseFullScreenActivity;
import com.csjbot.blackgaga.base.BasePresenter;
import com.csjbot.blackgaga.core.RobotManager;
import com.csjbot.blackgaga.feature.navigation.ArmLooper;
import com.csjbot.blackgaga.model.tcp.factory.ServerFactory;
import com.csjbot.blackgaga.push.BPush;
import com.csjbot.blackgaga.router.BRouterPath;
import com.csjbot.blackgaga.util.BlackgagaLogger;
import com.csjbot.coshandler.core.Robot;
import com.csjbot.coshandler.listener.OnNaviSearchListener;
import com.csjbot.coshandler.service.CsjlogService;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by jingwc on 2017/11/3.
 */

@Route(path = BRouterPath.UPBODY_TEST)
public class UpBodyTestActivity extends BaseFullScreenActivity {

    @Override
    protected BasePresenter getPresenter() {
        return null;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_upbody_test;
    }

    @BindView(R.id.tv_connect_state)
    TextView tv_connect_state;

    @Override
    public void init() {
        super.init();
        if (RobotManager.getInstance().getConnectState()) {
            tv_connect_state.setText("与Linux连接状态:已连接");
        } else {
            tv_connect_state.setText("与Linux连接状态:未连接");
        }

    }

    @OnClick(R.id.bt_open_bug_window)
    public void bt_open_bug_window() {
        startService(new Intent(this, CsjlogService.class));
    }

    @OnClick(R.id.bt_close_bug_window)
    public void bt_close_bug_window() {
        stopService(new Intent(this, CsjlogService.class));
    }

    @OnClick(R.id.bt_deny)
    public void denyAction() {
        ServerFactory.getActionInstance().denyAction();
    }

    @OnClick(R.id.bt_nod)
    public void nodAction() {
        ServerFactory.getActionInstance().nodAction();
    }

    @OnClick(R.id.bt_left_large_arm_up)
    public void bt_left_large_arm_up() {
        ServerFactory.getActionInstance().leftLargeArmUp();
    }

    @OnClick(R.id.bt_left_large_arm_down)
    public void bt_left_large_arm_down() {
        ServerFactory.getActionInstance().leftLargeArmDown();
    }

    @OnClick(R.id.bt_left_small_arm_up)
    public void bt_left_small_arm_up() {
        ServerFactory.getActionInstance().leftSmallArmUp();
    }

    @OnClick(R.id.bt_left_small_arm_down)
    public void bt_left_small_arm_down() {
        ServerFactory.getActionInstance().leftSmallArmDown();
    }

    @OnClick(R.id.bt_right_large_arm_up)
    public void bt_right_large_arm_up() {
        ServerFactory.getActionInstance().righLargeArmUp();
    }

    @OnClick(R.id.bt_right_large_arm_down)
    public void bt_right_large_arm_down() {
        ServerFactory.getActionInstance().rightLargeArmDown();
    }

    @OnClick(R.id.bt_right_small_arm_up)
    public void bt_right_small_arm_up() {
        ServerFactory.getActionInstance().rightSmallArmUp();
    }

    @OnClick(R.id.bt_right_small_arm_down)
    public void bt_right_small_arm_down() {
        ServerFactory.getActionInstance().rightSmallArmDown();
    }

    @OnClick(R.id.bt_set_alias)
    public void setAlias() {
        BPush.setAlias("test_xiao_xue");
    }

    @OnClick(R.id.bt_push)
    public void push() {
        Robot.getInstance().reqProxy.search();
        Robot.getInstance().setOnNaviSearchListener(new OnNaviSearchListener() {
            @Override
            public void searchResult(String json) {
                BlackgagaLogger.debug("收到查询结果：" + json);
            }
        });
    }

    ArmLooper looper = new ArmLooper();

    @OnClick(R.id.bt_start_loop)
    public void startLoop() {
        looper.startLooper();
    }

    @OnClick(R.id.bt_stop_loop)
    public void stopLoop() {
        looper.stopLooper();
    }

    @OnClick(R.id.bt_micro_volume)
    public void bt_micro_volume() {
        jumpActivity(TestMicroVolumeActivity.class);
    }
}
